package com.linhh.mall.center.server.service;

import com.linhh.mall.center.api.TbLandAttachmentService;
import com.linhh.mall.center.common.pojo.TbLandAttachment;
import com.linhh.mall.center.common.pojo.TbLandCoordinate;
import com.linhh.mall.center.server.mappers.TbLandAttachmentMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @Author linhh
 * @Date 2023 03 20 13 59
 **/
@Service
public class TbLandAttachmentServiceImpl implements TbLandAttachmentService {

    @Autowired
    private TbLandAttachmentMapper tbLandAttachmentMapper;

    @Override
    public List<TbLandAttachment> selectAll() {
        return tbLandAttachmentMapper.selectAll();
    }

    @Override
    public int addTbLandAttachment(TbLandAttachment tbLandAttachment) {
        tbLandAttachmentMapper.insertSelective(tbLandAttachment);
        return 1;
    }

    @Override
    public int deleteTbLandAttachment(Long id) {
        tbLandAttachmentMapper.deleteByPrimaryKey(id);
        return 1;
    }

    @Override
    public int updateTbLandAttachment(TbLandAttachment tbLandAttachment) {
        return tbLandAttachmentMapper.updateByPrimaryKey(tbLandAttachment);
    }

    @Override
    public TbLandAttachment selectAttachmentBy(Long id) {
        return tbLandAttachmentMapper.selectByPrimaryKey(id);
    }

    @Override
    public TbLandAttachment selectAttachmentByLandId(Long landId) {
        Example example = new Example(TbLandAttachment.class);
        example.createCriteria().andEqualTo("landId", landId);
        TbLandAttachment tbLandAttachment = tbLandAttachmentMapper.selectOneByExample(example);
        return tbLandAttachment;
    }
}
